# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgname=libredefender
pkgver=0.7.0
pkgrel=1
pkgdesc='Light-weight antivirus scanner for Linux'
url='https://github.com/kpcyrd/libredefender'
arch=('loong64' 'x86_64')
license=('GPL2')
depends=('libclamav.so' 'hicolor-icon-theme')
makedepends=('cargo' 'clang')
source=(https://github.com/kpcyrd/${pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz
        https://github.com/kpcyrd/${pkgname}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz.asc)
b2sums=('f9fd4e36737f849b39bbe250a5a67da493d9ad7881bc020a8b252dbe5c679202993d6dd0b2cbfa5eb78f5c16c31dd2af72093a1acdfe8b211e6e390c2124d186'
        'SKIP')

validpgpkeys=("64B13F7117D6E07D661BBCE0FE763A64F5E54FD6")

prepare() {
  cd "${pkgname}-${pkgver}"
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd ${pkgname}-${pkgver}
  cargo build --frozen --release
}

check() {
  cd ${pkgname}-${pkgver}
  cargo test --frozen
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 755 -t "${pkgdir}/usr/bin" \
    target/release/libredefender

  # install completions
  install -d "${pkgdir}/usr/share/bash-completion/completions" \
             "${pkgdir}/usr/share/zsh/site-functions" \
             "${pkgdir}/usr/share/fish/vendor_completions.d"
  "${pkgdir}/usr/bin/libredefender" completions bash > "${pkgdir}/usr/share/bash-completion/completions/libredefender"
  "${pkgdir}/usr/bin/libredefender" completions zsh > "${pkgdir}/usr/share/zsh/site-functions/_libredefender"
  "${pkgdir}/usr/bin/libredefender" completions fish > "${pkgdir}/usr/share/fish/vendor_completions.d/libredefender.fish"

  install -Dm 644 contrib/libredefender.desktop -t "${pkgdir}/etc/xdg/autostart"
  install -Dm 644 contrib/icon.svg "${pkgdir}/usr/share/icons/hicolor/scalable/apps/${pkgname}.svg"
  install -Dm 644 LICENSE-* -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
